/* 
 * File:   Node.h
 * Author: James
 *
 * Created on November 19, 2010, 4:12 PM
 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <iostream>
#include <string>
using namespace std;

#define RECEIVER_PORT 31337
//#define MSG_SIZE (1024*16) // 16kb msg size

#ifndef NODE_H
#define	NODE_H

class Node {
public:
    Node(bool receiv);
    Node(const Node& orig);
    virtual ~Node();
    
    struct sockaddr_in* getAddr();
    int conn(struct sockaddr_in*); // used by client
    int acc(struct sockaddr_in* client); // used by host
    void closeFD(char fd);
    int sendMsg(char* msg, char fd);
    int receive(char* msg, int maxBytes, char fd);
private:
    int socket_fd;
    int new_fd; // used by kdc/receiver to send data to initiator

    short port;
    struct sockaddr_in addr;
};

#endif	/* NODE_H */

